/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.kaetec.dao;

import br.com.kaetec.entities.Contato;
import java.util.Arrays;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Sergio Artero
 */
public class ContatoTableModel extends AbstractTableModel {

    private List<Contato> contatos;
    private List<String> colunas;
    
    public ContatoTableModel( List<Contato> contatos ){
        this.contatos = contatos;
        colunas = Arrays.asList("Tipo", "Conteudo");
    }
    
    @Override
    public String getColumnName( int column) {
        return colunas.get(column);
    }
    
    @Override
    public int getRowCount() {
        return contatos.size();
    }

    @Override
    public int getColumnCount() {
        return colunas.size();
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {

        Contato contato = contatos.get(rowIndex);
        
        switch (columnIndex){
            
            case 0: return contato.getTipoContato().getDescricao();
            case 1: return contato.getConteudo();
                
        }
        
        return null;
    }

    public List<Contato> getContatos() {
        return contatos;
    }

    public void setContatos(List<Contato> contatos) {
        this.contatos = contatos;
    }
    
}
